<template>
    <el-button>click</el-button>
    <ul>
        <li v-for="(item, idx) in list" :key="idx">{{ item.name }} -- {{ item.age }}</li>
    </ul>
</template>

<script>
import { getCurrentInstance, onMounted, reactive, toRefs } from 'vue';

export default {
    setup () {
        const { ctx } = getCurrentInstance();
        const state = reactive({
            list: [],
        });
        onMounted(() => {
            ctx.$http.get('http://localhost:8888').then((result) => {
                const { data } = result;
                state.list = data;
            }).catch((err) => {
                console.log(err);
            });
        });
        return {
            ...toRefs(state),
        };
    },
};
</script>

<style>

</style>
